
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>列表</title>
    {include file="include/top"}
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-inline">
                <label class="layui-form-label">级别</label>
                <div class="layui-input-inline">
                    <select name="level">
                        <option value="">筛选会员级别</option>
                        <option value="0">预注册</option>
                        <option value="1">会员</option>
                        <option value="2">合伙人</option>
                    </select>
                </div>
            </div>
            {include file="include/input" class2='layui-inline' type='text' title="昵称" name='nickname' value=''}
            {include file="include/input" class2='layui-inline' type='text' title="上级ID" name='pathID' value=''}

            <div class="layui-inline">
                <label class="layui-form-label">属性</label>
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="">筛选用户状态</option>
                        <option value="-1">禁用</option>
                        <option value="0">注册</option>
                        <option value="1">待审核</option>
                        <option value="2">已实名</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
            </div>
        </div>
<!--        <div class="layui-card-header layuiadmin-card-header-auto">-->
<!--            <button type="button" class="layui-btn layui-btn-warm" id="test-upload-type3" data-imgid="adduser"><i class="layui-icon"></i>批量停止</button>-->
<!--            <button type="button" class="layui-btn layui-btn-warm" id="test-upload-type4" data-imgid="adduser"><i class="layui-icon"></i>批量正常</button>-->
<!--        </div>-->
        <table class="layui-table" lay-data="{height:0, url:'usersList', page:true, id:'idTest',toolbar: '#toolbarDemo' ,cellMinWidth: 80}" lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{type:'checkbox'}"></th>
                <th lay-data="{field:'id',  sort: true, width:80}">ID</th>
                <th lay-data="{field:'nickname'}">昵称</th>
                <th lay-data="{field:'level',templet:function(d){
                    if(d.level==248){
                        return '商家';
                    }else if(d.level==236){
                        return '用户';
                    }else if(d.level==247){
                        return '店家';
                    }else{
                        return '游客';
                    }
                }}">级别</th>
                <th lay-data="{field:'pathid',templet:function(d){
                    return '<img src='+d.pathImg+' width=30>'+d.pathName;
                }}">上级</th>
                <th lay-data="{field:'username'}">姓名</th>
                <th lay-data="{field:'carID'}">身份证</th>
                <th lay-data="{field:'mobile'}">手机号</th>
                <th lay-data="{field:'status',templet:function(d){
                    if(d.status==-1){
                        return '禁用';
                    }else if(d.status==0){
                        return '注册';
                    }else if(d.status==1){
                        return '待审核';
                    }else if(d.status==2){
                        return '已审核';
                    }else{
                        return '正常';
                    }
                }}">状态</th>
                <th lay-data="{align:'center', toolbar: '#barDemo',width:280}"></th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="more">操作<i
                    class="layui-icon layui-icon-down"></i></a>
        </script>
        <script type="text/html" id="toolbarDemo"></script>
    </div>
</div>
<input type='file' id='upimg' name='file' style="display: none;">
{include file="include/js"}
<script>
    var pathid=0;
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'contlist', 'table','dropdown','upload'], function(){
        var table = layui.table;
        var $ = layui.$;
        var form = layui.form;
        var dropdown = layui.dropdown
        var pathid=0;
        var id=0;
        var selectIDS=[];
        var upload = layui.upload;
        var imgType=0;
        var imgSrc='';
        var field;
        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            field = data.field;
            //执行重载
            table.reload('idTest', {
                where: field,page:{curr:1}
            });
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听工具条
        table.on('tool(demo)', function(obj){
            var that = this
            var data = obj.data;
            if (obj.event === 'more') {
                //更多下拉菜单
                var thatData = data
                dropdown.render({
                    elem: that
                    , show: true //外部事件触发即显示
                    , data: [{
                        title: '实名审核'
                        , id: 'admin'
                    },{
                        title: '禁用'
                        , id: 'setDisable'
                    },
                    ]
                    , click: function (data, othis) {
                        //根据 id 做出不同操作
                        if (data.id === 'setDisable') {
                            id = thatData.id
                            delUser(obj)
                        }else if(data.id == 'admin'){
                            id = thatData.id
                            userAdd();
                        }
                    }
                    , align: 'right' //右对齐弹出（v2.6.8 新增）
                    , style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
                });
            }
        });
        function delUser($obj){
            layer.prompt({title:"禁用原因："},function (re){
                $.post("setDisable?userID="+id,{content:re},function (re) {
                    layer.closeAll()
                    layer.msg(re.msg);
                },'json');
            })
        }
        function userAdd(){
            layer.open({
                type: 2
                ,title: '实名审核'
                ,content: 'realMeAdmin?id='+id
                ,btn: ['通过','不通过并禁用', '取消']
                ,area: ['100%', '80%']
                ,btn1: function(index, layero){
                    var data={}
                    var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags");
                    data.status = othis.find('select[name="status"]').val()
                    if(data.status == -1){
                        layer.confirm("是否<font color='red'>解禁账户</font>并通过实名？",function (){
                            $.post("setDisable?status=2&userID="+id,function (re) {
                                if(re.code==0){
                                    layer.closeAll()
                                }
                                layer.msg(re.msg);
                            },'json');
                        })
                    }else{
                        layer.confirm("是否确定操作？",function (){
                            $.post("setDisable?status=2&userID="+id,function (re) {
                                if(re.code==0){
                                    layer.closeAll()
                                }
                                layer.msg(re.msg);
                            },'json');
                        })
                    }
                },btn2:function (){
                    delUser()
                }
            });
        }
    });
</script>

</body>
</html>
